﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Digitalmes.Services
{
    // 自定义日志服务接口
    public interface ILogService
    {
        void Information(string message);
        void Warning(string message);
        void Error(string message, Exception ex = null);
        void Debug(string message);
    }

    // Serilog 适配器实现
    public class SerilogAdapter : ILogService
    {
        private readonly Serilog.ILogger _logger;

        public SerilogAdapter(Serilog.ILogger logger = null)
        {
            _logger = logger ?? Serilog.Log.Logger;
        }

        public void Information(string message) => _logger.Information(message);

        public void Warning(string message) => _logger.Warning(message);

        public void Error(string message, Exception ex = null)
        {
            if (ex == null)
                _logger.Error(message);
            else
                _logger.Error(ex, message);
        }

        public void Debug(string message) => _logger.Debug(message);
    }



}
